package gao.xioalei.dao;

import gao.xioalei.entity.UserOnline;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

@Repository("UserOnlineDao")
public interface UserOnlineDao extends JpaRepository<UserOnline, String> {

    @Transactional//不知道为什么如果不加这个的话deleteBy****就不能在应用结束前执行,当deleteById可以
    public void deleteAllByRoutingKey(String routingKey);

    public List<UserOnline> findAllByUserId(String userId);

    public UserOnline findTopByUserIdOrderByOnLineTimeDesc(String userId);

}
